package com.study.system.eduadservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.system.eduadservice.entity.PromotionAd;
import com.study.system.eduadservice.mapper.PromotionAdMapper;
import com.study.system.eduadservice.service.PromotionAdService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * service实现类
 */
@Service
public class PromotionAdServiceImpl extends ServiceImpl<PromotionAdMapper, PromotionAd> implements PromotionAdService {

    @Resource
    private PromotionAdMapper promotionAdMapper;

    @Cacheable(cacheNames = "ad",key = "T(String).valueOf(#spaceId)")
    @Override
    public List<PromotionAd> getPromotionAdsBySpaceId(Integer spaceId) {
        List<PromotionAd> promotionAds = promotionAdMapper.selectList(
                new QueryWrapper<PromotionAd>().lambda().eq(PromotionAd::getSpaceId,spaceId));
        return promotionAds;
    }
}
